(in-package #:mcclim-fontconfig)

(pkg-config-cflags "fontconfig")

(include "fontconfig/fontconfig.h")

(ctype fc-bool "FcBool")
(ctype fc-char32 "FcChar32")
(ctype fc-char8 "FcChar8")

(constant (+fc-false+ "FcFalse"))
(constant (+fc-true+ "FcTrue"))
(constant (+fc-dontcare+ "FcDontCare"))
(constant (+fc-charset-map-size+ "FC_CHARSET_MAP_SIZE"))
(constant (+fc-charset-done+ "FC_CHARSET_DONE"))

(constant (+fc-weight-thin+ "FC_WEIGHT_THIN"))
(constant (+fc-weight-extralight+ "FC_WEIGHT_EXTRALIGHT"))
(constant (+fc-weight-ultralight+ "FC_WEIGHT_ULTRALIGHT"))
(constant (+fc-weight-light+ "FC_WEIGHT_LIGHT"))
(constant (+fc-weight-demilight+ "FC_WEIGHT_DEMILIGHT"))
(constant (+fc-weight-semilight+ "FC_WEIGHT_SEMILIGHT"))
(constant (+fc-weight-book+ "FC_WEIGHT_BOOK"))
(constant (+fc-weight-regular+ "FC_WEIGHT_REGULAR"))
(constant (+fc-weight-normal+ "FC_WEIGHT_NORMAL"))
(constant (+fc-weight-medium+ "FC_WEIGHT_MEDIUM"))
(constant (+fc-weight-demibold+ "FC_WEIGHT_DEMIBOLD"))
(constant (+fc-weight-semibold+ "FC_WEIGHT_SEMIBOLD"))
(constant (+fc-weight-bold+ "FC_WEIGHT_BOLD"))
(constant (+fc-weight-extrabold+ "FC_WEIGHT_EXTRABOLD"))
(constant (+fc-weight-ultrabold+ "FC_WEIGHT_ULTRABOLD"))
(constant (+fc-weight-black+ "FC_WEIGHT_BLACK"))
(constant (+fc-weight-heavy+ "FC_WEIGHT_HEAVY"))
(constant (+fc-weight-extrablack+ "FC_WEIGHT_EXTRABLACK"))
(constant (+fc-weight-ultrablack+ "FC_WEIGHT_ULTRABLACK"))
(constant (+fc-slant-roman+ "FC_SLANT_ROMAN"))
(constant (+fc-slant-italic+ "FC_SLANT_ITALIC"))
(constant (+fc-slant-oblique+ "FC_SLANT_OBLIQUE"))
(constant (+fc-width-ultracondensed+ "FC_WIDTH_ULTRACONDENSED"))
(constant (+fc-width-extracondensed+ "FC_WIDTH_EXTRACONDENSED"))
(constant (+fc-width-condensed+ "FC_WIDTH_CONDENSED"))
(constant (+fc-width-semicondensed+ "FC_WIDTH_SEMICONDENSED"))
(constant (+fc-width-normal+ "FC_WIDTH_NORMAL"))
(constant (+fc-width-semiexpanded+ "FC_WIDTH_SEMIEXPANDED"))
(constant (+fc-width-expanded+ "FC_WIDTH_EXPANDED"))
(constant (+fc-width-extraexpanded+ "FC_WIDTH_EXTRAEXPANDED"))
(constant (+fc-width-ultraexpanded+ "FC_WIDTH_ULTRAEXPANDED"))
(constant (+fc-proportional+ "FC_PROPORTIONAL"))
(constant (+fc-dual+ "FC_DUAL"))
(constant (+fc-mono+ "FC_MONO"))
(constant (+fc-charcell+ "FC_CHARCELL"))
(constant (+fc-rgba-unknown+ "FC_RGBA_UNKNOWN"))
(constant (+fc-rgba-rgb+ "FC_RGBA_RGB"))
(constant (+fc-rgba-bgr+ "FC_RGBA_BGR"))
(constant (+fc-rgba-vrgb+ "FC_RGBA_VRGB"))
(constant (+fc-rgba-vbgr+ "FC_RGBA_VBGR"))
(constant (+fc-rgba-none+ "FC_RGBA_NONE"))
(constant (+fc-hint-none+ "FC_HINT_NONE"))
(constant (+fc-hint-slight+ "FC_HINT_SLIGHT"))
(constant (+fc-hint-medium+ "FC_HINT_MEDIUM"))
(constant (+fc-hint-full+ "FC_HINT_FULL"))
(constant (+fc-lcd-none+ "FC_LCD_NONE"))
(constant (+fc-lcd-default+ "FC_LCD_DEFAULT"))
(constant (+fc-lcd-light+ "FC_LCD_LIGHT"))
(constant (+fc-lcd-legacy+ "FC_LCD_LEGACY"))

(cenum (fc-type)
       ((:fc-type-unknown "FcTypeUnknown"))
       ((:fc-type-void "FcTypeVoid"))
       ((:fc-type-integer "FcTypeInteger"))
       ((:fc-type-double "FcTypeDouble"))
       ((:fc-type-string "FcTypeString"))
       ((:fc-type-bool "FcTypeBool"))
       ((:fc-type-matrix "FcTypeMatrix"))
       ((:fc-type-char-set "FcTypeCharSet"))
       ((:fc-type-ft-face "FcTypeFTFace"))
       ((:fc-type-lang-set "FcTypeLangSet"))
       ;; Range disabled as it's not available on debian-9
       #+nil ((:fc-type-range "FcTypeRange")))

(cenum (fc-result)
       ((:fc-result-match "FcResultMatch"))
       ((:fc-result-no-match "FcResultNoMatch"))
       ((:fc-result-type-mismatch "FcResultTypeMismatch"))
       ((:fc-result-no-id "FcResultNoId"))
       ((:fc-result-out-of-memory "FcResultOutOfMemory")))

(cenum (fc-match-kind)
       ((:fc-match-pattern "FcMatchPattern"))
       ((:fc-match-font "FcMatchFont"))
       ((:fc-match-scan "FcMatchScan")))

(cstruct fc-matrix "FcMatrix"
         (xx "xx" :type :double)
         (xy "xy" :type :double)
         (yx "yx" :type :double)
         (yy "yy" :type :double))

(cstruct fc-value "FcValue"
         (type "type" :type fc-type)
         (value-fchar8 "u.s" :type :pointer)
         (value-int "u.i" :type :int)
         (value-bool "u.b" :type fc-bool)
         (value-double "u.d" :type :double)
         (value-matrix "u.m" :type (:pointer (:struct fc-matrix)))
         (value-char-set "u.c" :type :pointer)
         (value-ptr "u.f" :type :pointer)
         (value-lang-set "u.l" :type :pointer)
         ;; Range disabled as it's not available on debian-9
         #+nil (value-range "u.r" :type :pointer))

(cstruct fc-font-set "FcFontSet"
         (nfont "nfont" :type :int)
         (sfont "sfont" :type :int)
         (fonts "fonts" :type :pointer))
